//
//  EventLogCell.m
//  ConvenientlyTake
//
//  Created by 森鑫 on 2022/12/23.
//

#import "EventLogCell.h"
#import "TGShowPhotoView.h"
#import "EventDetailModel.h"

@implementation EventLogCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.tipLabel.layer.cornerRadius = 2;
    self.tipLabel.layer.borderColor = RGBA(0, 180, 42, 1).CGColor;
    self.tipLabel.layer.borderWidth = 1;
 
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    // Configure the view for the selected state
}

//- (void)setModel:(EventLogModel *)model{
//    self.photoView.imgUrlArray = @[@"1" , @"2"];
//}
-(void)fillDataWith:(EventLogModel *)model andTitleString:(NSString *)titleString{
    self.model = model;
    self.titleLabel.text = R(model.eventName);
    self.timeLabel.text = R(model.operateTime);
    self.tipLabel.hidden = YES;
    if (self.dataArray.count == 1) {
        self.topLineView.hidden = YES;
        self.bottomLineView.hidden = YES;
    } else if  (self.indexPath.row == 0) {
        self.topLineView.hidden = YES;
        self.bottomLineView.hidden = NO;
    } else if (self.indexPath.row == (self.dataArray.count - 1)){
        self.topLineView.hidden = NO;
        self.bottomLineView.hidden = YES;
    } else {
        self.topLineView.hidden = NO;
        self.bottomLineView.hidden = NO;
    }
    if([model.eventName isEqualToString:@"发起"]) {
        self.operationPeopleLabel.text = @"发起人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.hidden = NO;
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = YES;
        self.leftReviewLabel.text = @"";
        self.reviewResultLabeel.hidden = YES;
        self.reviewResultLabeel.text = @"";
        self.leftRemarkView.hidden = YES;
        self.leftRemarkView.text = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.photoView.hidden = YES;
        self.reviewResultTopSpace.constant = 0;
        self.remarkTopSpace.constant = 0;
        self.photoTopSpace.constant = 0;
    } else if ([model.eventName isEqualToString:@"不予受理"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"原因：";
        self.orderStatusLabel.text = model.problemDescription.length?model.problemDescription:@"无";
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = YES;
        self.leftReviewLabel.text = @"";
        self.reviewResultLabeel.hidden = YES;
        self.reviewResultLabeel.text = @"";
        self.leftRemarkView.hidden = YES;
        self.leftRemarkView.text = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.reviewResultTopSpace.constant = 0;
        self.remarkTopSpace.constant = 0;
        if (model.serviceFileList.count > 0) {
            self.photoView.hidden = NO;
            self.photoTopSpace.constant = 8;
            self.photoView.imgUrlArray = model.photoArray;
        } else {
            self.photoTopSpace.constant = 0;
            self.photoView.hidden = YES;
        }
        
    }else if ([model.eventName isEqualToString:@"指派"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        self.leftReviewLabel.hidden = NO;
        self.reviewResultLabeel.hidden = NO;
        self.leftReviewLabel.text = @"备注：";
        self.reviewResultLabeel.text =model.remark.length?model.remark:@"无";
        
        self.leftRemarkView.hidden = YES;
        self.leftRemarkView.text = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.photoView.hidden = YES;
        self.reviewResultTopSpace.constant = 8;
        self.remarkTopSpace.constant = 0;
        self.photoTopSpace.constant = 0;
    }else if ([model.eventName isEqualToString:@"驳回指派"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = NO;
        self.reviewResultLabeel.hidden = NO;
        self.leftReviewLabel.text = @"驳回原因：";
        self.reviewResultLabeel.text = model.remark.length?model.remark:@"无";
        
        self.leftRemarkView.hidden = NO;
        self.leftRemarkView.text = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.photoView.hidden = YES;
        self.reviewResultTopSpace.constant = 8;
        self.remarkTopSpace.constant = 0;
        self.photoTopSpace.constant = 0;
    }else if ([model.eventName isEqualToString:@"处置保存"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = NO;
        self.reviewResultLabeel.hidden = NO;
        self.leftReviewLabel.text = @"内容：";
        self.reviewResultLabeel.text = model.remark.length?model.remark:@"无";
    
        self.leftRemarkView.hidden = YES;
        self.leftRemarkView.text  = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.reviewResultTopSpace.constant = 8;
        self.remarkTopSpace.constant = 0;
        if (model.serviceFileList.count > 0) {
            self.photoView.hidden = NO;
            self.photoView.imgUrlArray = model.photoArray;
            self.photoTopSpace.constant = 8;
        } else {
            self.photoTopSpace.constant = 0;
            self.photoView.hidden = YES;
        }
    }else if ([model.eventName isEqualToString:@"处置提交"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = NO;
        self.reviewResultLabeel.hidden = NO;
        self.leftReviewLabel.text = @"内容：";
        self.reviewResultLabeel.text = model.remark.length?model.remark:@"无";
    
        self.leftRemarkView.hidden = YES;
        self.leftRemarkView.text = @"";
        self.remarkView.hidden = YES;
        self.remarkView.text = @"";
        self.reviewResultTopSpace.constant = 8;
        self.remarkTopSpace.constant = 0;
        if (model.serviceFileList.count > 0) {
            self.photoView.hidden = NO;
            self.photoView.imgUrlArray = model.photoArray;
            self.photoTopSpace.constant = 8;
        } else {
            self.photoTopSpace.constant = 0;
            self.photoView.hidden = YES;
        }
    }else if ([model.eventName isEqualToString:@"处置审核"]) {
        self.operationPeopleLabel.text = @"操作人：";
        self.peopleLabel.text = [NSString stringWithFormat:@"%@(%@)" , R(model.operatorName),R(model.phoneNumber)];
        self.tipLabel.text = [model getPromoterString];
        self.leftOrderLabel.text = @"单据状态：";
        self.orderStatusLabel.text = R(model.eventStateName);
        // 需要隐藏的部分
        self.leftReviewLabel.hidden = NO;
        self.reviewResultLabeel.hidden = NO;
        self.leftReviewLabel.text = @"审核结果：";
        self.reviewResultLabeel.text = R(model.auditStateName);
    
        self.leftRemarkView.hidden = NO;
        self.remarkView.hidden = NO;
        self.leftRemarkView.text = @"内容：";
        self.remarkView.text = model.remark.length?model.remark:@"无";
        self.reviewResultTopSpace.constant = 8;
        self.remarkTopSpace.constant = 8;
        if (model.serviceFileList.count > 0) {
            self.photoView.hidden = NO;
            self.photoView.imgUrlArray = model.photoArray;
            self.photoTopSpace.constant = 8;
        } else {
            self.photoTopSpace.constant = 0;
            self.photoView.hidden = YES;
        }
    }
}

@end
